/*
 * io.h
 *
 * Controle de dispositivos de Entrada e Saída,
 * como teclado e monitor, por exemplo.
 *
 *  Created on: 22/09/2010
 *      Author: wendell
 */

#ifndef IO_H_
#define IO_H_

#define BUFFSIZE 10

#include <system.h>

// io/io.c
unsigned char inportb (ushort);
void outportb (ushort, uchar);
void port_wait(void);
void outport_wait(unsigned short, unsigned char);
unsigned char inport_wait(unsigned short);

// io/buffer.c

typedef struct {
	uchar buffer[BUFFSIZE];
	int first;
	int last;
	int nitens;
} Buffer;

void flush(Buffer*);
void initBuffer(Buffer*);
void bufferInsert(Buffer*, unsigned char);
uchar bufferPop(Buffer*);
uchar firstBuffer(Buffer*);
bool bufferIsEmpty(Buffer*);
bool bufferIsFull(Buffer*);
int sizeBuffer(Buffer*);

// io/io.c
uchar getchar(void);
void gets(char*);


#endif /* IO_H_ */
